import 'package:flutter/cupertino.dart';
import 'package:get/get.dart';

import '../../common/utils/status_util.dart';


/// @author zavier
/// @time 2022/11/12 16:01
/// @des 带状态管理的StatelessWidget基类

abstract class BaseStateLessView<T extends GetxController> extends StatelessWidget {
  const BaseStateLessView({Key? key}) : super(key: key);


  T get controller => GetInstance().find<T>(tag: tag);

  ///Get 局部更新字段
  get updateId => null;

  get dark => true;
  get tag =>null;

  @protected
  Widget buildContent(BuildContext context);

  void onBuild() {}

  @override
  Widget build(BuildContext context) {
    onBuild();
    StatusBarUtils.setTransparentBar(isDark: dark);
    return GetBuilder<T>(
        id: updateId,
        builder: (controller) {
          return buildContent(context);
        });
  }
}
